<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ page isELIgnored="false" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

<html>
<head>
    <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
<link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style>
html,body {
	margin: 0;
	padding: 0;
	font-size: 85%;
}
</style>
<script >
    
     var qieye = 0;
	 $(function(){
	 //queryNum();
	 $("#yind").button();
    $("#chax").button(); 
    $("#excel").button();
	 $("#excel").hide();
    $("#reset").button();
        
    loadTab(0);
    //queryNum();
    
    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#tabs" ).tabs({
		    select: function(event, ui) {
		    var i =ui.index;	    
		    if(i==''){
		    i="0";
		    }
		    qieye = i;
		    loadTab(i);
		    //$("#myTab"+qieye).jqGrid('setGridParam',{url:'findVerifyHtxxList.action?index='+qieye,mtype:'post',page:1}).trigger("reloadGrid");
		   // alert("aa");
		    //jQuery("#myTab1").jqGrid('hideCol',["Verify"]);
		      //  queryNum();
            //return false;
  		  }
		
	});
	
	
 });
  

	
	function loadTab(i){	
	if(i==0){
	loadBdxx(i);
	}else{
	loadYdxx(i);
	}
    
  $("#myTab"+i).jqGrid('setGridHeight','300px');
  }
  
  
  function loadBdxx(i){
      $("#myTab"+i).jqGrid({      
    url:'findydbdlist?mmlx=5&index='+i,  
    datatype: 'json',
    mtype: 'post',         
	colNames:['操作','报单号','出卖人','发货单位名称','煤种','品种','价格类型','价格','报单数量','应单数量','剩余数量','隶属行业','报单日期'],
   	colModel:[ 
   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	    {name:'baodbm',index:'baodbm', width:90},
   	    {name:'baodrdwmc',index:'baodrdwmc', width:150},
   		{name:'shdwmc',index:'shdwmc', width:150},
   		{name:'meizmc',index:'meizmc', width:40 },	
   		{name:'pinzmc',index:'pinzmc', width:40 },
   	    {name:'jiaglxmc',index:'jiaglxmc', width:60 },
   		{name:'danj',index:'danj', width:40 },
   		{name:'shul',index:'shul', width:60 },
   		{name:'ydsl',index:'ydsl', width:60 },
   		{name:'shengysl',index:'shengysl', width:60 },
   		 
   		{name:'lismc',index:'lismc', width:60 },
   		{name:'baodsj',index:'baodsj', width:65}		
   	],
   	   
   	    jsonReader: {
   	           repeatitems : false, 
   	           id: 'baodbm'
   	         },    	
   	   	rowNum:10,
   	   	width : 1200,
   shrinkToFit:false,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,   	
   	rownumbers: true,   	 
    viewrecords: true,
    //multiselect: sign,
    sortorder: 'desc',  
    altRows:true,  
	//caption: "报单列表",
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs'); 
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j];			
			verify ="<a href='#' style='color:#f60' onclick='Verify("+ id +")'>应单</a>&nbsp;|&nbsp;<a href='#' style='color:#f60' onclick='selectbd("+ id +")'>查看</a>";
					
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 	
  });
  }
  
  function loadYdxx(i){
      $("#myTab"+i).jqGrid({      
    url:'findydbdlist?mmlx=5&index='+i,  
    datatype: 'json',
    mtype: 'post',         
    colNames:['操作','应单号','买受人','收货单位名称','煤种','品种','价格类型','价格','出卖人','应单数量','应单日期'],
   	colModel:[ 
   	   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   	   	    {name:'yingdbm',index:'yingdbm', width:120},
   	   	    {name:'baodrdwmc',index:'baodrdwmc', width:150},
   			{name:'shdwmc',index:'shdwmc', width:150},
   			{name:'meizmc',index:'meizmc', width:40 },	
   			{name:'pinzmc',index:'pinzmc', width:40 },
   		    {name:'jiaglxmc',index:'jiaglxmc', width:60 },
   			{name:'danj',index:'danj', width:40 },
   			{name:'shul',index:'shul', width:60 },
   	   		{name:'yingdsl',index:'yingdsl', width:60 },
   	   		{name:'yingdsj',index:'yingdsj', width:65}		
   	   	],
   	   
   	    jsonReader: {
   	           repeatitems : false, 
   	           id: 'yingdbm'
   	         },   
   	    width : 1200,
   	   	rowNum:10,
    shrinkToFit:false,
   	rowList:[10,20,30],     	
   	pager: '#pager'+i,   	
   	rownumbers: true,   	 
    viewrecords: true,
    //multiselect: sign,
    sortorder: 'desc',  
    altRows:true,  
	//caption: "报单列表",
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#myTab"+i).jqGrid('getDataIDs'); 
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j];			
			verify ="<a href='#' style='color:#f60' onclick='select("+ id +")'>编辑|查看</a>";						
			jQuery("#myTab"+i).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 	
	
  });
  $("#myTab"+i).jqGrid('setGridHeight','250px');
  }
  
  
  function openwindow(url){
    var sheight = screen.height-70;
    var swidth = screen.width-10;
    var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
    var result=window.showModalDialog(url,window,winoption);
    if(result ==1){
    	if (qieye==0){
   		 reloadYdxx(); 	
   	} 
   	if (qieye==1){
   		jQuery("#myTab1").trigger("reloadGrid"); 
  	} 
     }
    return result;  
}
  
  function reloadYdxx(){
   window.location.href="<%=request.getContextPath()%>/gpjy/sellydlist";
}
  
   function Verify(id) { //单击修改链接的操作 
  
	openwindow('<%=path%>/gpjy/gpydCmryd?bdbh='+id.id+'&lx=1');
 
}
 
  function select(id) { //单击修改链接的操作 
		 var rowData = jQuery("#myTab"+qieye).jqGrid("getRowData", id.id);  
 
	openwindow('<%=path%>/gpjy/gpydCmryd?yingdbh='+rowData.yingdbh+'&lx=2');
 
}

function selectbd(id) { //单击修改链接的操作 
  
	 var rowData = jQuery("#myTab"+qieye).jqGrid("getRowData", id.id);  
	 
		openwindow('<%=path%>/gpjy/gpydCmryd?yingdbh='+rowData.yingdbh+'&lx=2');
 
}

  // 查询
function search(){   
  var formdata = $("#form1").serialize(); 
 // alert(formdata); 
  $("#myTab"+qieye).jqGrid('setGridParam',{url:'findydbdlist?'+formdata+'&mmlx=5&index='+qieye,mtype:'post',page:1}).trigger("reloadGrid"); 
 
  //queryNum();
 
}

function queryNum(){   
  var formdata = $("#form1").serialize(); 
  $.post("<%=path%>/gpjy/findYdxxList4Num.action?index="+qieye+"&",formdata,function(data,textStatus)
  {
  
  var json = eval('(' + data + ')');

  var re=/(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
if (json[0].zongsl !="")
{
   //alert("价格范围："+json[0].jiag + "  总数量："+json[0].shul+"  总金额："+json[0].jine);
   $("#queryNum").html("价格范围："+json[0].zongjg + "元/吨  总数量："+json[0].zongsl.toString().replace(re,"$1,")+"吨  总金额："+json[0].zongje.toString().replace(re,"$1,")+"元");
 }else
			{			
			 $("#queryNum").html("价格范围：0 元/吨  总数量：0 吨  总金额：0 元");
			} 
  });
  
}

function txt_onblur(i) {
            if (!event.srcElement.value) {
                event.srcElement.value = '0';
            }
           
            if (isNaN(temp)) {
                $("#"+i).val(0);                
            } 
        }
        
        //重置
			function resetSearch(){
			   $('#list_search  input[type=text]').val('');
			   $('#list_search select').val('-1');
			 }
        //导出excel
        function dc_excel(){ 
        var formdata = $("#form1").serialize(); 
	form1.action="<%=path%>/htgl/findVerifyHtxxList_excel.action?index="+qieye;
	form1.method = "post";
	form1.submit();
	}
	</script>
</script>
</head>

<body>
	<div class="container">
  <div class="containerbox">
   
    <div class="search mt10" id="list_search">
    <form id="form1" method="post">
    <table width="90%" border="0" cellspacing="0" cellpadding="0" class="search-table">
  <tr>
    <td align="left" valign="middle" class="search-table-300"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">报单编号</td>
    <td align="left"><input name="aa" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle" class="search-table-300"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">煤种</td>
    <td align="left"><select name="bb" class="form-textbox" style="width: 200px;">
      <option value="-1" selected>==请选择==</option>
                   <c:forEach var="mz" items="${meiz}">
                   <option value="${mz.diccode}">
                   ${mz.dicname}
                   </option>
                   </c:forEach>
                 </select>
                 
                 </td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">品种</td>
    <td align="left"><select name="cc" class="form-textbox" style="width: 200px;">
      <option value="-1" selected>==请选择==</option>
                   <c:forEach var="pz" items="${pinz}">
                   <option value="${pz.diccode}">
                   ${pz.dicname}
                   </option>
                   </c:forEach>
                 </select></td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">买受人</td>
    <td align="left"><input name="oo" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">发货单位</td>
    <td align="left"><input name="ff" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">收货单位</td>
    <td align="left"><input name="ee" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
  </tr>
  <tr>
   
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">报单日期</td>
    <td align="left"><input name="gg" type="text" class="form-textbox" style="width: 93px;"  id="datepicker"/>--
    <input name="hh" type="text" class="form-textbox" style="width: 93px;"  id="datepicker1"/></td>
  </tr>
</table></td>
<td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">价格</td>
    <td align="left"><input name="ii" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" />--
    <input name="jj" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">价格</td>
    <td align="left"><input name="pp" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" />--
    <input name="qq" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
  </tr>
</table></td>
  </tr>
    <tr>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">隶属行业</td>
    <td align="left"><select name="dd" class="form-textbox" style="width: 200px;">
       <option value="-1" selected>==请选择==</option>
                   <c:forEach var="hy" items="${hangy}">
                   <option value="${hy.diccode}">
                   ${hy.dicname}
                   </option>
                   </c:forEach>
    </select></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">发站（局）</td>
    <td align="left"><input name="nn" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">到站（局）</td>
    <td align="left"><input name="mm" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
  </tr>
   <tr>
    <td align="left" valign="middle" colspan="3"><table border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td align="right" class="pr10 search-table-70">&nbsp;</td>
    <td align="left"><input name="" type="button" class="form-button-query form-button" value="查询" onclick="search();"/>
    <input name="" type="button" class="form-button-reset form-button" value="重置"  onclick="resetSearch();"/></td>
  </tr>
</table></td>
  </tr>
    </table>
</form></div>
			
   <div id="tabs">
			<ul>
				<li><a href="#tabs-0">待应单</a></li>
				<li><a href="#tabs-1">已应单</a></li>
				<li id="queryNum"  style="float:right; vertical-align: bottom; line-height:20px; top: 3px;"></li>
			</ul>
			<div id="tabs-0">
				<table id="myTab0" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager0" class="scroll"></div>
				<div id="message0" class="scroll"></div>
			</div>
			<div id="tabs-1">
				<table id="myTab1" class="scroll" cellpadding="0" cellspacing="0"></table>
				<div id="pager1" class="scroll"></div>
				<div id="message1" class="scroll"></div>
			</div>

		</div>

		<div id="dialog-confirm" title="是否确认？"></div>
    
  </div>
</div> 
</body>
</html>
